
import unittest

from com.yhzy.oa.oa_index import Index
from com.yhzy.oa.oa_user import User


class IndexTestCase(unittest.TestCase):


    @classmethod
    def setUpClass(cls) -> None:
        # 用户登录 提取token
        user = User()
        # 获取验证码
        codeResp = user.getCode()
        uuid = codeResp.json()["uuid"]
        # 登录
        admin = {"username": "admin", "password": "admin123", "uuid": uuid, "code": 9999}
        loginResp = user.login(admin)
        # 提取响应的token信息
        cls.token = loginResp.json()["token"]

        cls.index = Index()

    def test_info(self):
        resp = self.index.getUserInfo(self.token)
        self.assertIn("操作成功",resp.text)

    def test_route(self):
        resp = self.index.getUserRoute(self.token)
        self.assertIn("操作成功",resp.text)

if __name__ == '__main__':
    unittest.main()